package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.mapper.CommodityMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CourierServiceMapper;
import com.ruoyi.system.domain.CourierService;
import com.ruoyi.system.service.ICourierServiceService;

/**
 * 快递代拿Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@Service
public class CourierServiceServiceImpl implements ICourierServiceService 
{
    @Autowired
    private CourierServiceMapper courierServiceMapper;

    @Autowired
    private CommodityMapper commodityMapper;
    /**
     * 查询快递代拿
     * 
     * @param couId 快递代拿ID
     * @return 快递代拿
     */
    @Override
    public CourierService selectCourierServiceById(Long couId)
    {
        return courierServiceMapper.selectCourierServiceById(couId);
    }

    /**
     * 查询快递代拿列表
     * 
     * @param courierService 快递代拿
     * @return 快递代拿
     */
    @Override
    public List<CourierService> selectCourierServiceList(CourierService courierService)
    {

        System.out.println(courierService);
        return courierServiceMapper.selectCourierServiceList(courierService);
    }

    /**
     * 新增快递代拿
     * 
     * @param courierService 快递代拿
     * @return 结果
     */
    @Override
    public int insertCourierService(CourierService courierService)
    {
        courierService.setCreateTime(DateUtils.getNowDate());
        courierServiceMapper.insertCourierService(courierService);
        System.out.println("----"+courierService);
        for (int i = 0; i < courierService.getCommodityList().size(); i++) {
            courierService.getCommodityList().get(i).setComCouId(courierService.getCouId());
            courierService.setCreateTime(DateUtils.getNowDate());
            commodityMapper.insertCommodity( courierService.getCommodityList().get(i));
        }

        return 1;
    }

    /**
     * 修改快递代拿
     * 
     * @param courierService 快递代拿
     * @return 结果
     */
    @Override
    public int updateCourierService(CourierService courierService)
    {
        return courierServiceMapper.updateCourierService(courierService);
    }

    /**
     * 批量删除快递代拿
     * 
     * @param couIds 需要删除的快递代拿ID
     * @return 结果
     */
    @Override
    public int deleteCourierServiceByIds(Long[] couIds)
    {
        return courierServiceMapper.deleteCourierServiceByIds(couIds);
    }

    /**
     * 删除快递代拿信息
     * 
     * @param couId 快递代拿ID
     * @return 结果
     */
    @Override
    public int deleteCourierServiceById(Long couId)
    {
        return courierServiceMapper.deleteCourierServiceById(couId);
    }


    //代取快递详情
    @Override
    public CourierService detail(Long couIds) {
        return courierServiceMapper.detail(couIds);
    }
}
